# 批量重命名mp4文件
import os

def renameFiles():
    f = open("目录.txt", "r")
    mytextLinesList = f.readlines()

    dirList = os.listdir("./")                                      # 当前目录的文件夹和文件
    fileList = [x for x in dirList if os.path.isfile(x)]            # 过滤掉文件夹, 留下文件
    mp4FileList = filerListIn(fileList, ".mp4")                     # 只留下mp4文件

    for (filename, newname) in zip(mp4FileList, mytextLinesList):
        os.rename(filename, newname.strip())                        # newname含有换行符, 须去掉
        print(filename)
        print(newname)
        print("====================================")


# 过滤掉含containStr的元素
def filerListOut(srcList, containStr):
    newList = [x for x in srcList if x.find(containStr) == -1]
    return newList

# 保留含containStr的元素
def filerListIn(srcList, containStr):
    newList = [x for x in srcList if x.find(containStr) != -1]
    return newList

    

# renameFiles()



